package com.syj.jsxjj.ui.lend.fragment;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.syj.jsxjj.R;
import com.syj.jsxjj.app.App;
import com.syj.jsxjj.config.Constant;
import com.syj.jsxjj.ui.lend.bean.HomeBean;
import com.syj.jsxjj.widget.recycler.BaseRecyclerAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * {@link RecyclerView.Adapter} that can display a {@link } and makes a call to the
 * specified {@link }.
 * TODO: Replace the implementation with code for your data type.
 */
public class MyProductListRecyclerViewAdapter extends BaseRecyclerAdapter<MyProductListRecyclerViewAdapter.ViewHolder, HomeBean.PlateList2Bean> {


    @Override
    public ViewHolder mOnCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.fragment_productlist, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void mOnBindViewHolder(ViewHolder holder, int position) {
        Glide.with(mContext).load(Constant.IMG_URL+item.getCompanyLogo()).into(holder.mIvLogo);
        holder.mTvName.setText(item.getProductName());
        holder.mTvContent.setText(item.getKeyRifi());
        holder.mTvRate.setText("最低利率:"+item.getRate()+"%");
        holder.mTvSuccess.setText("申请成功"+item.getApplySuccessNum()+"人");
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.iv_logo)
        ImageView mIvLogo;
        @BindView(R.id.tv_name)
        TextView mTvName;
        @BindView(R.id.tv_content)
        TextView mTvContent;
        @BindView(R.id.tv_rate)
        TextView mTvRate;
        @BindView(R.id.tv_success)
        TextView mTvSuccess;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
